package com.coocaa.aries.core.config;

import com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceBuilder;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;

import javax.sql.DataSource;

/**
 * @author : bijiahao
 * @date : 2019/4/9.
 * @description:<p> </p>
 */
@Configuration
@MapperScan(basePackages = {"com.coocaa.aries.**.mapper"})
public class MyBatisPlusConfig {
    /**
     * <code>@Primary</code>标明当有多个同类型的Bean存在时，以此为准
     *
     * @return
     */
    @Primary
    @Bean
    @ConfigurationProperties("spring.datasource.druid.first")
    public DataSource firstDataSource() {
        DataSource dataSource = DruidDataSourceBuilder.create().build();
        return dataSource;
    }

}
